import type { ClientCacheServiceResult } from "./ClientCache";

export const ClientDocService = (cache: ClientCacheServiceResult) => {
  return {
    /**
     * 插入一个文档
     */
    async insertDoc(id: string, index: string, data: string) {
      const client = await cache.getClientCache(id);
      return await client.insertDoc(index, data);
    },

    /**
     * 更新一个文档
     */
    async updateDoc(id: string, index: string, docId: string, data: string) {
      const client = await cache.getClientCache(id);
      return await client.updateDoc(index, docId, data);
    },

    /**
     * 删除多个索引
     */
    async deleteBatchDoc(id: string, index: string, docIds: Array<string>) {
      const client = await cache.getClientCache(id);
      return await client.deleteBatchDoc(index, docIds);
    }
  };
};
